<?php

$params = require(__DIR__ . '/params.php');

$config = [
    'id' => 'yudianv2',
    'language' => 'zh-CN',
    'defaultRoute'=>'index/index', 
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'components' => [
        'request' => [
            'cookieValidationKey' => 'feeeeeee',
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,//隐藏index.php 
            'enableStrictParsing' => false,
            //'suffix' => '',//后缀，如果设置了此项，那么浏览器地址栏就必须带上.html后缀，否则会报404错误
            'rules' => [
                //'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
                // '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                // '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                // '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
                // '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
             ],
        ],

        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => '120.26.62.108',
            'password' => 'fee123fee',
            'port' => 6379,
            'database' => 0,
        ],

        'cache' => [
            'class' => 'yii\redis\Cache',
        ],
        
        'user' => [
            'identityClass' => 'app\models\Users',
        ],
        'errorHandler' => [
            'errorAction' => 'index/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'useFileTransport' => false,
            'transport' => [
                            'class' => 'Swift_SmtpTransport',
                            'host' => 'smtp.163.com',
                            'username' => 'yudianedu1@163.com',
                            'password' => 'nckmlbsfalhujltu',
                            'port' => '25',
                            'encryption' => 'tls',
                            ], 
            'messageConfig'=>[  
                'charset'=>'UTF-8',  
                'from'=>['yudianedu1@163.com'=>'雨点教育']  
            ],  
        ],
        'i18n' => [
            'translations' => [
                'app*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@app/messages',
                    'fileMap' => [
                        'app' => 'app.php'
                    ],
                ],
            ],
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'], //'info','trace',
                ],
            ],
        ],
        'db' => require(__DIR__ . '/db.php')
    ],

    'aliases' => [
        '@Tools' => '@app/vendor/Tools',
        '@JPush' => '@app/vendor/jpush/jpush/src/JPush',
    ],

    'modules' => [
        'Rest' => [
            'class' => 'app\modules\Rest\Module',
        ],
        'Op' => [
            'class' => 'app\modules\Op\Module',
        ],
    ],
    
    'params' => $params,
];

if (YII_ENV_DEV) {
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
    ];

}

return $config;
